package com.text.day2_1.homework;

import java.math.BigDecimal;
import java.util.Random;

public class Fight extends Hero{
    private double anger;

    public Fight() {

    }

    public Fight(double anger) {
        this.anger = anger;
    }

    public Fight(String name, double power, double zhiLi, double mingJie, double anger) {
        super(name, power, zhiLi, mingJie);
        this.anger = anger;
    }

    public void hsAttack() {
        Random random = new Random();
        double number = random.nextDouble() * 0.4 - 0.2 + 1;
        BigDecimal two = new BigDecimal(number * this.getPower());
        if (this.anger >= 20) {
            System.out.println("英勇打击");
            System.out.println("攻击力：" + two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() * 2);
            this.anger -= 20;
            System.out.println("消耗20怒气值，还有" + this.anger + "怒气值");
        } else
            System.out.println("怒气值不够，无法释放英勇打击");

    }

    public double getAnger() {
        return anger;
    }

    public void setAnger(double anger) {
        this.anger = anger;
    }

    @Override
    public String toString() {
        return  "Fight{" +
                "name='" + getName() + '\'' +
                ", power=" + getPower() +
                ", zhiLi=" + getZhiLi() +
                ", mingJie=" + getMingJie() +
                ", anger=" + anger +
                '}';
    }
}
